﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TestManagerClient
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
        }

        #region Metody odpowiedzialne za kontrolę zawartości ramki głównej

        private void GoToPageExecuteHandler(object sender, ExecutedRoutedEventArgs e)
        {
            mainFrame.NavigationService.Navigate(new Uri((string)e.Parameter, UriKind.Relative));
        }

        private void GoToPageCanExecuteHandler(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }

        #endregion

        #region Metody obsługujące przyciski menu górnego

        private void logOutButton_Click(object sender, RoutedEventArgs e)
        {
            var panel = new LoginWindow();
            this.Close();
            panel.Show();
        }

        private void profileButton_Click(object sender, RoutedEventArgs e)
        {
            profileButton.Command = NavigationCommands.GoToPage;
            profileButton.CommandParameter = "Pages/ProfilePage.xaml";
        }

        private void coursesButton_Click(object sender, RoutedEventArgs e)
        {
            coursesButton.Command = NavigationCommands.GoToPage;
            coursesButton.CommandParameter = "Pages/CoursesPage.xaml";
        }

        private void questionsButton_Click(object sender, RoutedEventArgs e)
        {
            questionsButton.Command = NavigationCommands.GoToPage;
            questionsButton.CommandParameter = "Pages/QuestionsPage.xaml";
        }

        private void testsButton_Click(object sender, RoutedEventArgs e)
        {
            testsButton.Command = NavigationCommands.GoToPage;
            testsButton.CommandParameter = "Pages/TestsPage.xaml";
        }

        private void resultsButton_Click(object sender, RoutedEventArgs e)
        {
            resultsButton.Command = NavigationCommands.GoToPage;
            resultsButton.CommandParameter = "Pages/ResultsPage.xaml";
        }

        private void helpButton_Click(object sender, RoutedEventArgs e)
        {
            var panel = new HelpWindow();
            panel.Show();
        }

        private void minimizeButton_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void maximizeButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.WindowState == WindowState.Maximized)
            {
                this.WindowState = WindowState.Normal;
            }
            else
            {
                this.WindowState = WindowState.Maximized;
            }
        }

        private void quitButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        #endregion

        #region Metody obsługujące przyciski związane z oknem aplikacji

        private void dragButton_Click(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                DragMove();
            }
        }

        private void sizeChanged_Event(object sender, SizeChangedEventArgs e)
        {
            double height = this.Height;
            double width = this.Width;
            mainView.Height = height - topMenuGrid.Height - 13;
            mainView.Width = width - 13;
        }

        private void stateChanged_Event(object sender, EventArgs e)
        {
            if (this.WindowState == WindowState.Maximized)
            {
                maximizeButton.Content = "▼";
            }
            else
            {
                maximizeButton.Content = "▲";
            }
        }

        #endregion
    }
}
